package com.example.myapplication.adapter;


import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;
/**
 * FragmentAdapter类继承自FragmentPagerAdapter类，用于管理Fragment的适配器
 */
public class FragmentAdapter extends FragmentPagerAdapter {
private List<Fragment> fragmentList;
private  List<String> tabList;
public FragmentAdapter(FragmentManager fm,List<Fragment> fragmentLIst,List<String> tabList){
    super(fm);
    this.fragmentList = fragmentList;
    this.tabList = tabList;
}
    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    /**
     * 获取Fragment的数量
     * @return Fragment的数量
     */
    @Override
    public int getCount() {
        return fragmentList.size();
    }

    /**
     * 获取指定位置的标签
     * @param position 位置索引
     * @return 对应位置的标签
     */
    @Override
    public CharSequence getPageTitle(int position) {
        return tabList.get(position);
    }
}